
import { axiosError, defaultErrorMessage } from 'src/util/errorHandler';
import http from 'src/util/http';


type PostAuthMeRequest = any
type PostAuthMeResponse = any


// 读取银行列表getSystemConfig
const getSysBank = async (data: PostAuthMeRequest) => {
    try {
        return await http.post<PostAuthMeResponse, PostAuthMeRequest>(`SysConfig/getSysBank`);
    } catch (e) {
        const error = axiosError(e);
        throw defaultErrorMessage(error);
    }
};

// 取公告列表
const getNotice = async (data: PostAuthMeRequest) => {
    try {
        return await http.post<PostAuthMeResponse, PostAuthMeRequest>(`SysConfig/getNotice?top=${data.top}&token=${data.token}`);
    } catch (e) {
        const error = axiosError(e);
        throw defaultErrorMessage(error);
    }
};

// 取公告列表
const getNoticeInfo = async (data: PostAuthMeRequest) => {
    try {
        return await http.post<PostAuthMeResponse, PostAuthMeRequest>(`SysConfig/getNoticeInfo/${data.id}?token=${data.token}`);
    } catch (e) {
        const error = axiosError(e);
        throw defaultErrorMessage(error);
    }
};

// 读取推送信息
const getMyPushMsg = async (data: PostAuthMeRequest) => {
    try {
        return await http.post<PostAuthMeResponse, PostAuthMeRequest>(`SysConfig/getMyPushMsg?FUserID=${data.FUserID}&token=${data.token}`);
    } catch (e) {
        const error = axiosError(e);
        throw defaultErrorMessage(error);
    }
};
// 取公告列表
const updatePushMsg = async (data: PostAuthMeRequest) => {
    try {
        return await http.post<PostAuthMeResponse, PostAuthMeRequest>(`SysConfig/updatePushMsg?FID=${data.FID}&token=${data.token}`);
    } catch (e) {
        const error = axiosError(e);
        throw defaultErrorMessage(error);
    }
};
export default {
    getSysBank,
    getNotice,
    getNoticeInfo,
    getMyPushMsg,
    updatePushMsg,
};
